package com.fengzhi.web.dao.core.impl;

import java.io.Serializable;

import org.apache.log4j.Logger;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;

import com.fengzhi.web.dao.core.IBasicDao;

/**
 * 
 * @Description: TODO(基类)
 * @author fyf
 * @date 2016年10月20日 上午9:33:45
 * @version v1.0
 */
public class BasicDaoImpl extends HibernateDaoSupport implements IBasicDao {
	public Logger log = Logger.getLogger(getClass().getName());

	public <T> void save(T entity) {
		log.info("保存实体对象");
		this.getHibernateTemplate().save(entity);
	}

	@Override
	public <T> void delete(T entity) {
		log.info("删除实体对象");
		this.getHibernateTemplate().delete(entity);
	}

	@Override
	public <T> void update(T entity) {
		log.info("更新实体对象");
		this.getHibernateTemplate().update(entity);
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public <T> T getById(Class entityClass, Serializable id) {
		log.info("根据id和实体类获取实体对象");
		return (T) this.getHibernateTemplate().get(entityClass, id);
	}

}
